﻿//-----------------------------------------------------------------------
// <copyright file="BooleanToVisibility.cs" company="Microsoft Corporation">
//     Copyright Microsoft Corporation. All Rights Reserved. This code released under the terms of the Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.) This is sample code only, do not use in production environments.
// </copyright>
//-----------------------------------------------------------------------
namespace Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.Converters
{
    using System;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Data;

    /// <summary>
    /// Boolean to visibility converter
    /// </summary>
    public class BooleanToVisibility : IValueConverter
    {
        /// <summary>
        /// Gets or sets a value indicating whether true means visible.
        /// </summary>
        /// <value><c>true</c> if true means visible; otherwise, <c>false</c>.</value>
        public bool TrueMeansVisible { get; set; }

        /// <summary>
        /// Converts the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="language">The language.</param>
        /// <returns>Visibility of the object</returns>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var input = (bool)value;
            if (this.TrueMeansVisible)
            {
                return input ? Visibility.Visible : Visibility.Collapsed;
            }
            
            return input ? Visibility.Collapsed : Visibility.Visible;
        }

        /// <summary>
        /// Converts the back.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="language">The language.</param>
        /// <returns>Nothing</returns>
        /// <exception cref="System.NotImplementedException">Always throws this exception.</exception>
        public object ConvertBack(object value, System.Type targetType, object parameter, string language)
        {
            throw new System.NotImplementedException();
        }
    }
}
